package com.yz.android_baozou.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by Administrator on 2016/10/31.
 */

public class My_FragmentPagerAdapter extends android.support.v4.app.FragmentPagerAdapter {
    private String[] mArray_Top ;
    private List<Fragment> mList_ViewPager ;

    //获取mArray_Top，mList_ViewPager
    public My_FragmentPagerAdapter(FragmentManager fm, String[] _mArray_Top, List<Fragment> _mList_ViewPager) {
        super(fm);
        this.mArray_Top = _mArray_Top;
        this.mList_ViewPager = _mList_ViewPager;
    }

    @Override
    //根据下标获取碎片
    public Fragment getItem(int position) {
        return mList_ViewPager!=null?mList_ViewPager.get(position):null;
    }

    @Override
    //获取list的数目
    public int getCount() {
        return mList_ViewPager!=null?mList_ViewPager.size():0;
    }

    //根据下标获取title
    @Override
    public CharSequence getPageTitle(int position) {
        return mArray_Top[position];
    }
}
